package com.mssh.login.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 熳殊沙华
 * @Date: 2025/03/27/11:36
 * @Description:
 */
@Component
public class AuthConfig {

    // 秘钥
    @Value("${auth.jwt.secret}")
    private String secret;

    // 超时时间
    @Value("${auth.jwt.expire:3600}")
    private int expire;

    // 刷新token的时间范围
    @Value("${auth.jwt.refresh:300}")
    private int refresh;

    //图形验证码宽度
    @Value("${kaptcha.image.width:120}")
    private String width;

    //图形验证码高度
    @Value("${kaptcha.image.height:40}")
    private String height;

    //图形验证码位数
    @Value("${kaptcha.verify-code.length:4}")
    private String length;

    //图形验证码有效期
    @Value("${kaptcha.verify-code.expire:5}")
    private int verifyCodeExpire;

    // 静态变量桥接
    private static AuthConfig instance;

    // 通过 @PostConstruct 将实例变量赋值给静态变量
    @PostConstruct
    public void init() {
        instance = this;
    }

    // 静态方法供 JwtUtil 调用
    public static String getSecret() {
        return instance.secret;
    }

    public static int getExpire() {
        return instance.expire;
    }

    public static int getRefresh() {
        return instance.refresh;
    }

    public static String getWidth() {
        return instance.width;
    }

    public static String getHeight() {
        return instance.height;
    }

    public static String getLength() {
        return instance.length;
    }

    public static int getVerifyCodeExpire() {
        return instance.verifyCodeExpire;
    }
}
